@extends('layouts.supervisor')

@section('content')
<div class="page-content">

	<div class="row">

		<div class="col-xs-12">

			<h3 class="header smaller lighter blue">学生选题列表</h3>

			<div class="table-responsive">

				<table id="sample-table-2" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>学生姓名</th>
							<th>学生论文题目</th>
							<th>审核结果</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						@foreach($approvedStudents as $approvedStudent)
						<tr>
							<td>
								<a href="/supervisor/thesis/checktitle/{{$approvedStudent->id}}" >{{$approvedStudent->user->name}}</a>
							</td>
							<td>@if ($approvedStudent->thesis != null && $approvedStudent->title->count() > 0) 
								{{$approvedStudent->title->last()->title}}
								@else 该生暂未提交论文题目
								@endif
							</td>
							<td>
								@if ($approvedStudent->thesis != null && $approvedStudent->title->count() > 0) 
									@if ($approvedStudent->thesis->approved)
									审核通过
									@else
									等待评阅
									@endif
								@endif
							</td>
							<td>
									<button class="btn btn-pink btn-sm" onclick="window.location.href='/supervisor/thesis/checktitle/{{$approvedStudent->id}}'">
												<i class="icon-edit"></i>
												评阅
											</button>
							</td>
						</tr>
						@endforeach
					</tbody>

				</table>
				<form style="display: none" id="title-form" name="title-form" class="form-horizontal" method="POST" action="/supervisor/thesis/storetitle" >
					{{ csrf_field() }}
					<input type="text" class="col-xs-10 col-sm-5" id='student' name="student" value="" />
				</form>

			</div>
			
		</div>

	</div>
</div>
<script type="text/javascript">
	function check_title(student) {
		$('#student').val(student);
		$('#title-form').submit();
	}
</script>
@endsection

